package com.shuo.xhlc.房屋出租系统.view;

import com.shuo.xhlc.房屋出租系统.domain.Houst;
import com.shuo.xhlc.房屋出租系统.servict.HouseServise;

import java.util.Scanner;

public class houserview {

    private boolean loop = true;
    private int key = 0 ;
    Scanner scanner = new Scanner(System.in);
    private HouseServise houseServise = new HouseServise(10);//创建HouseServise，设置数组大小为10

    public void listHoustes(){
        System.out.println("===========房屋列表===========");
        System.out.println("编号\t\t房主\t\t电话\t\t地址\t\t月租\t\t状态（已出租/未出租）");
        Houst[] housts = houseServise.list();//得到所有房屋信息
        for (int i = 0; i < housts.length; i++) {   //有坑
            if (housts[i] == null){
                break;
            }
            System.out.println(housts[i]);
        }
        System.out.println("=========房屋列表显示完毕=======");
    }


    public void mainmeau(){
        do {
            System.out.println("----------房屋出租系统----------");
            System.out.println("\t\t\t1.新 增 房 源");
            System.out.println("\t\t\t2.查 找 房 屋");
            System.out.println("\t\t\t3.删 除 房 屋 信 息");
            System.out.println("\t\t\t4.修 改 房 屋 信 息");
            System.out.println("\t\t\t5.显 示 房 屋 信 息");
            System.out.println("\t\t\t6.退出");
            System.out.println("请输入你的选择1-6");

            key = scanner.nextInt();
            switch (key){
                case 1 :
                    System.out.println("新增");
                    break;
                case 2 :
                    System.out.println("查找");
                    break;
                case 3 :
                    System.out.println("删除");
                    break;
                case 4 :
                    System.out.println("修改");
                    break;
                case 5 :
                    listHoustes();
                    break;
                case 6 :
                    System.out.println("退出");
                    loop = false;
                    break;
            }

        }while (loop);

    }
}
